package com.example.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.example.entity.dto.ParkingFeeConfigDTO;
import com.example.service.ParkingFeeConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/parking/fee/config")
@Api(tags = "停车收费配置管理")
public class ParkingFeeConfigController {

    @Autowired
    private ParkingFeeConfigService parkingFeeConfigService;

    @PostMapping
    @ApiOperation("创建停车收费配置")
    public R<Boolean> createConfig(@RequestBody ParkingFeeConfigDTO dto) {
        return R.ok(parkingFeeConfigService.createConfig(dto));
    }

    @PutMapping("/{id}")
    @ApiOperation("更新停车收费配置")
    public R<Boolean> updateConfig(@PathVariable Long id, @RequestBody ParkingFeeConfigDTO dto) {
        return R.ok(parkingFeeConfigService.updateConfig(id, dto));
    }

    @GetMapping("/{id}")
    @ApiOperation("获取停车收费配置详情")
    public R<ParkingFeeConfigDTO> getConfig(@PathVariable Long id) {
        return R.ok(parkingFeeConfigService.getConfig(id));
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除停车收费配置")
    public R<Boolean> deleteConfig(@PathVariable Long id) {
        return R.ok(parkingFeeConfigService.deleteConfig(id));
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用/禁用停车收费配置")
    public R<Boolean> changeStatus(@PathVariable Long id, @PathVariable Integer status) {
        return R.ok(parkingFeeConfigService.changeStatus(id, status));
    }
}
